package pers.qianyu.month_202011.date_20201111;

/**
 * 面试题 17.16. 按摩师
 * https://leetcode-cn.com/problems/the-masseuse-lcci/
 *
 * @author mizzle rain
 * @date 2020-11-11 22:12
 */
public class Massage {
    public int massage(int[] nums) {
        if (nums == null || nums.length == 0) {
            return 0;
        }
        int[] dp = new int[nums.length + 1];
        dp[1] = nums[0];
        for (int i = 2; i < dp.length; i++) {
            dp[i] = Math.max(nums[i - 1] + dp[i - 2], dp[i - 1]);
        }
        return dp[dp.length - 1];
    }
}
